package com.dg.cuckoo.admin.action.projectDeclare.oneProDeclare;

import com.dg.cuckoo.admin.dto.projectDeclare.oneProDeclare.ProAmountDeclareDto;
import com.dg.cuckoo.admin.service.ProAmountDeclareService;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 项目申报-2021年项目申报-已完工项目资金
 */
@RestController
@RequestMapping("/projectDeclare/oneProDeclare/proAmountDeclare")
public class ProAmountDeclare extends BaseController {

    @Autowired
    private ProAmountDeclareService service;

    /**
     * 新增
     */
    @PostMapping("save")
    public JsonResult<Void> save(ProAmountDeclareDto dto, MultipartFile[] files) throws Exception {
        service.save(dto,files);
        return new JsonResult<>(OK);
    }

//    /**
//     * 新增里点击项目名称显示数据
//     */
//    @PostMapping("openNameInfo")
//    public JsonResult<BasicProjectDto> openNameInfo(String projectName){
//
//    }

    /**
     * 删除
     */
    @PostMapping("delect/{id}")
    public JsonResult<Void> delect(@PathVariable String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }

    /**
     * 导入
     */

    /**
     * 分页
     * @param page 页
     * @param pageSize 页数
     * @return
     */
    @PostMapping("page/{page}/{pageSize}")
    public JsonResult<PageModel> page(@PathVariable Integer page,@PathVariable Integer pageSize){
        PageModel data = service.page(page, pageSize);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击显示数据
     */
    @PostMapping("openInfo/{id}")
    public JsonResult<String> openInfo(@PathVariable String id){
        String data = service.openInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 修改
     */
    @PostMapping("update")
    public JsonResult<Void> update(String id, ProAmountDeclareDto dto, MultipartFile[] files) throws Exception {
        service.update(id,dto,files);
        return new JsonResult<>(OK);
    }

}
